package ckw.database.model;

import java.awt.Color;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import core.communication.message.NodeStateEnum;

@Embeddable
public class NodeState {

	@Column(name = "state")
	@Enumerated(EnumType.STRING)
	private NodeStateEnum stateEnum;

	@Column(name = "modifiedDate")
	@Temporal(TemporalType.TIMESTAMP)
	private Date modifiedDate;

	public NodeState() {

	}

	public NodeState(NodeStateEnum stateEnum) {
		this.stateEnum = stateEnum;
	}

	public void prePersist() {
		this.modifiedDate = new Date();
	}

	public NodeStateEnum getStateEnum() {
		return stateEnum;
	}

	public void setStateEnum(NodeStateEnum stateEnum) {
		this.stateEnum = stateEnum;
	}

	public Color getColor() {
		return stateEnum.getColor();
	}

	public Date getModifiedDate() {
		return modifiedDate;
	}

	public void setModifiedDate(Date modifiedDate) {
		this.modifiedDate = modifiedDate;
	}
}
